<template>
  <div>
      <button @click="btn">点击按钮随机显示名字</button>
      <p>{{uname}}</p>
  </div>
</template>

<script>
export default {
    data () {
        return {
            arr:["小花", "小明", "小可爱", "小王"],
            index:'',
            uname:''
        }
    },
    methods:{
        btn(){
            this.index = Math.floor((Math.random()*this.arr.length))
            this.uname = this.arr[this.index]
        }
    }
}
</script>

<style>

</style>